﻿//Copyright (c) Microsoft Corporation.  All rights reserved.

using Microsoft.Ted.Wacel.Base;
using System;

namespace Microsoft.Ted.Wacel.Redis
{
    public class Cube:Base.Cube
    {
        public Cube(string name, string hostName, int port = 6379, string password = null)
            : base(name,
                 new MasterDetails<string, string>(name + ":batches",
                    new RedisCacheProvider(new BookSleeve.RedisConnection(hostName, port, allowAdmin:true, password:password), name + ":batches") {Configuration = new RedisConfiguration()},
                    new RedisLockProvider(new BookSleeve.RedisConnection(hostName, port, allowAdmin: true, password: password), name + ":batchlocks")),
                new RedisCacheProvider(new BookSleeve.RedisConnection(hostName, port, allowAdmin: true, password: password), name) { Configuration = new RedisConfiguration() },
                new RedisLockProvider(new BookSleeve.RedisConnection(hostName, port, allowAdmin: true, password: password), name))
        {

        }

        public static Cube GetSimpleCube(string hostName, int port = 6379)
        {
            Cube ret = new Cube("simplecube", hostName, port);
            ret.AddDimension(Dimension.GetTimeDimensionMonthDays(DateTime.Now.Year));
            return ret;
        }
    }
}
